﻿<?php
require('conn.php');
require('functions.php');
require('session.php');
//print_r($session);

//修改资料
if($_POST){
	//$wx=guolv(trim($_POST['wx']));
	//$pass=guolv(trim($_POST['pass']));
	$uid=guolv(trim($_POST['uid']));
	$realname=guolv(trim($_POST['realname']));
	$nick=guolv(trim($_POST['nick']));
	$alipay=guolv(trim($_POST['alipay']));
	$pic=guolv(trim($_POST['pic']));
	$phone=guolv(trim($_POST['phone']));
	$wx=guolv(trim($_POST['wx']));


	if(is_phone($phone)==false){
		echo "<script>alert('请输入正确的手机号');location.href='zl.php'</script>";
		exit;
	}
	
	if($pic==""){
		echo "<script>alert('请上传收款图片.方便提现!');location.href='ucenter.php'</script>";
		exit;	
			
	}
	  


	$mysql->execute("update `userdata` set `phone`='{$phone}',`alipay`='{$alipay}',`pic`='{$pic}',`realname`='{$realname}',`wx`='{$wx}' where `id`='{$uid}'");
	echo "<script>alert('修改成功');location.href='zl.php'</script>";
	exit;
	
}
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>用户资料 - <?php echo $config['sitename']?></title>
<meta name="keywords" content="<?php echo $config['sitename']?>,用户资料" />
<meta name="description" content="<?php echo $config['sitename']?>用户资料">
<link href="Css1/base.css" rel="stylesheet" type="text/css" />
<link href="Css1/header.css" rel="stylesheet" type="text/css" />
<link href="Css1/weiui.css" rel="stylesheet" type="text/css" />
<link href="Css1/information.css" rel="stylesheet" type="text/css" />
<link href="Css1/record.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php echo $site?>/editor/themes/default/default.css" />
<link rel="stylesheet" href="<?php echo $site?>/editor/plugins/code/prettify.css" />

<script charset="utf-8" src="<?php echo $site?>/editor/kindeditor.js"></script>
<script charset="utf-8" src="<?php echo $site?>/editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="<?php echo $site?>/editor/plugins/code/prettify.js"></script>
<script type=text/javascript > var app="/user" </script>
<script type="text/javascript" src="Scripts1/jquery.min.js"></script>
<script type=text/javascript src="Scripts1/jquery.common.js"></script>

</head>

<body class="mhome">

 <div id="content">
 <?php include('header.php')?>
<script>
	(function () {
		var menustate = document.getElementById('g-menustate');
		menustate.addEventListener("click", function (e) {
			if (menustate.checked) {
				$('#g-menustate').addClass('g-noscroll')
			}else {
				$('#g-menustate').removeClass('g-noscroll')
			}
		});
	})();
</script>
<script>
	KindEditor.ready(function(K) {
		var uploadbutton = K.uploadbutton({
			button : K('#uploadButton')[0],
			fieldName : 'imgFile',
			url : '<?php echo $site?>/editor/php/upload_json.php?dir=image',
			afterUpload : function(data) {
				if (data.error === 0) {
					var url = K.formatUrl(data.url, 'absolute');
					K('#cardid2').val(url);
                    $.post("<?php echo $site?>/editor/php/dunling.php",{
                    url:url
                    },function(slta,sltb){
                    //****//
                    });
				} else {
					alert(data.message);
				}
			},
			afterError : function(str) {
				alert('自定义错误信息: ' + str);
			}
		});
		uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});
	});
</script>
<div class="user-profile l-container l-top-padding l-bottom-padding addr-edit">
	
    		<form action="zl.php" method="post" name="form1">
    <section class="avatar">
		<img src="" onerror="javascript:this.src='/avatar/1/moderate.jpg';" onClick="update_info_msg();">
	</section>
	<section class="main">
		<li class="info line">
			<span class="title">手机号</span>
			<span class="content">
				<input name="phone" type="text"  id="name" reg=" " value="<?php echo $userdata['phone']?>"  msg="手机号" class="addr-mobile"></span>
		</li>
		<li class="info line">
			<span class="title">ID</span>
			<span class="content">
		<?php echo $session['id']?></span>
		</li><input type="hidden" value="<?php echo $session['id']?>" name="uid">
	 	<input value="<?php echo $userdata['phone']?>"  name="phone"   type="hidden" />
        
            <li class="info line"><span class="title">收款姓名</span><input name="realname" type="text"  id="name" reg=" " value="<?php echo $userdata['realname']?>"  msg="真实姓名，用于提现" class="addr-mobile"></li>            <li class="info line"><span class="title">支付宝</span><input name="alipay" type="text"  id="cardid" reg=" " value="<?php echo $userdata['alipay']?>"  msg="支付宝账号，用于提现" class="addr-mobile"></li>
            <li class="info line"><span class="title">支付宝收款码</span><input name="pic" type="text"  id="cardid2" reg=" " value="<?php echo $userdata['pic']?>"  msg="支付宝账号，用于提现" class="addr-mobile"><input type="button" id="uploadButton" value="提现收款图片"/></p></li>
      
                        <li class="info line"><span class="title">QQ号</span><input name="wx" type="text"  id="weichat" " value="<?php echo $userdata['wx']?>"  msg="请输入QQ号" class="addr-mobile"></li>                        <!--hook-->
                        <!--hook end-->
	</section>
	<a href="##" class="g-btn g-btn-medium-major" name="getcash"  onclick="send(2);">立即修改</a>
</div>

</form>

<script>
	(function () {
		setTimeout(function(){
		$('#g-footer').addClass('show');
		},1000);
	})();
</script>
<footer class="g-footer" id="g-footer">
	 
	<p><i class="iconfont">&#xe605;</i> 您的收入安全由阳光保险承保</p>
	 
</footer><div class="pop pop1" style="display: none;">
  <p class="error">
  </p>
</div>
<script type="text/javascript">
	
	//提示窗口
	function errShow(content){
		$('.error').html(content);
		$('.pop1').show();
		setTimeout("errHide()",1000);
	}
	
	//隐藏错误提示
	function errHide(){
		$('.pop1').hide();
		$('.error').text('');
		$("#error").html('');
		;
	}
	
	//登陆提示
	function loginShow(content){
		$('.error').html(content);
		$('.pop1').show();
	}
	
	//点击关闭错误提示
	$('.pop').live('click',function(){
		errHide();
	})
</script> 
<script type="text/javascript">
function checkEmail(str){
        return true;
}
	$(function() {
		 
		$("#weichat").bind( "blur", function() {
			if ($("#weichat").val() == '') {
				errShow("微信号不能为空！",1);
			}
		});
		$("#cardid").bind( "blur", function() {
		if ( !checkEmail($("#cardid").val())) {
				errShow("支付宝帐号应为邮箱或手机号！",1);
			}
		});
	})
	function send(num) {
				var account=$("#cardid").val();
				if(!checkEmail(account)){
				errShow("支付宝帐号应为邮箱或手机号！",1);
				return false;
				}else{
                 document.form1.submit();
                }
				 
			

	}
	function update_info(){
				window.location.href ="/ucenter.php"; 
	}
	function update_info_msg(){
    if(confirm("请确认回个人中心？"))
    {
        update_info();
    }
	}
	</script>
<div style="display: none;">
</div>
</div>
 
</body>
</html>
